<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>查看变量类型</title>
	</head>
	<body>
		<script>
			//定义变量
			var age=20;
			var name='xy';
			var sex=true;
			//查看变量的类型
			console.log(typeof(age));
			console.log(typeof(name));
			console.log(typeof(sex));
			
			//变量类型由谁来决定
			age="xy";
			console.log(typeof(age));
			
			var a=function(){
				alert("hello");
			};
			console.log(typeof a);
			
			var b=document;
			console.log(typeof (b));
			
			console.log("---------------");
			var flag=true;
			console.log(type flag);
			//布尔值只有两个值，true和false
			//转换为false的值：0，空字符串，NaN,null,undefined
			
			console.log(Boolean(0));
			//其他都转换为true
			console.log(Boolean('a'));
			
			//2)作用
			   //1、判断条件结果为true或false
			   var result=(1>3);
			   console.log(result);
			   
			   //2、判断是否有值
			   var result2='a';
			   if(result2){
			   	console.log("有");
			   }else{
			   	console.log("无");
			   }
			   
		</script>
	</body>
</html>
